import urllib


class website_base(object):
    def __init__(self, website_url, image_base_path, save_file_path):
        self.website_url = website_url
        self.image_base_path = image_base_path
        self.save_file_path = save_file_path

    def download_cartoon(self):
        # 1、获取章节链接、每个章节的页数
        dire_list = self.get_dict()
        # 2、获取图片地址
        # image_object_list = self.get_image_url(dire_list)
        # print(image_object_list)
        # # 3、下载图片
        # self.download_image(image_object_list)

    def get_dict(self):
        # {'title': '39', 'href': 'http://www.ikanman.com/comic/7747/106029.html', 'page_count': 16}, {'title': '38', 'href': 'http://www.ikanman.com/comic/7747/103841.html', 'page_count': 15}
        print("-" * 8 + "正在获取漫画目录......" + "-" * 8)
        image_base_html = self.get_image_base_html()
        image_dict = self.get_image_dict_from_html(image_base_html)
        print("-" * 8 + "获取漫画目录完成" + "-" * 8)
        print("共{page}话".format(page=len(image_dict)))
        return image_dict

    def get_image_base_html(self):
        image_base = urllib.request.urlopen(self.image_base_path)
        image_base_html = image_base.read().decode("utf-8")
        return image_base_html

    def get_image_dict_from_html(self, image_base_html):
        return []

    def get_image_url(self, dire_list):
        print("base_get_image_url")
        return

    def download_image(self, image_object_list):
        print("base_download_image")
        return
